/**
 * Created by gaoyj on 2018/6/28.
 */
window.onload = function (ev) {
    topbar.hide();
};
initProvinces();
$("#quickSetting").validate({
    rules: {
        minPrice: {
            range: [0.5, 1.0]
        }, maxPrice: {
            range: [0.5, 1.0]
        }

    }
});

function initProvinces() {
    var str = '';
    for (var i = 0; i < zone.length; i++) {
        str += '<label class="icheck" style="margin-right:10px;">' +
            '<input name="areas" type="checkbox" value="' + zone[i] + '">' + zone[i] + '</label>';
    }
    $("#areaSet").html(str);
}


$("#formSubmit").click(function () {
    var v = $("#quickSetting").valid();
    if (!v) {
        return;
    }
    if($('input[name=productTypes]:checked').length < 1){
        layer.msg("请选择运营商");
        return;
    }
    if($('input[name=faces]:checked').length < 1){
        layer.msg("请选择面值");
        return;
    }
    if($('input[name=areas]:checked').length < 1){
        layer.msg("请选择销卡地区");
        return;
    }
    $.confirm({
        title: '确认!',
        content: '确定提交吗？',
        confirm: function() {
            submitForm();
        }})
});


function submitForm() {
    $.post("/product/setProductStatus", $("#quickSetting").serialize(), function (data) {
        layer.msg(data.message);
    }).error(function (e) {
        layer.msg(e);
    });
}